var TabManager = function(sitemap, coord){
	var _map = {};
	
	this.addTab = function(pageId, tabId){
		var oldTab = _map[pageId];
		if(oldTab && oldTab != tabId){
			//remove old tab: 
			//forward next page
			chrome.tabs.remove(oldTab);
		}
		var otherPage = this.tab2page(tabId);
		if(otherPage && otherPage != pageId){
			//stack
		}
		_map[pageId] = tabId;
	}
	
	this.containsTab = function(tabId){
		return this.tab2page(tabId);
	}
	
	
	this.tabUpdate = function(tab){
		if(this.containsTab(tab.id)){
			return 1;
		}
		var pTab = tab.openerTabId;
		if(pTab && this.containsTab(pTab)){
			return 2;
		}
		
		//never reach
		return 0;
	}
	
	this.tab2page = function(tabId){
		for(var pId in _map){
			if(tabId == _map[pId]){
				return pId;
			}
		}
	}
}
